package com.zkthink.ceres.order.entity;

import cn.afterturn.easypoi.excel.annotation.Excel;
import cn.afterturn.easypoi.excel.annotation.ExcelEntity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import com.zkthink.base.entity.Entity;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.Range;
import java.time.LocalDateTime;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.Accessors;

import static com.baomidou.mybatisplus.annotation.SqlCondition.LIKE;
import static com.zkthink.utils.DateUtils.DEFAULT_DATE_TIME_FORMAT;

/**
 * <p>
 * 实体类
 * 订单表
 * </p>
 *
 * @author JustArgo
 * @since 2020-05-31
 */
@Data
@NoArgsConstructor
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("ceres_order")
@ApiModel(value = "Order", description = "订单表")
@AllArgsConstructor
public class Order extends Entity<Long> {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty("商户id")
    @TableField("tenant_code")
    private String tenantCode;

    /**
     * 店铺id
     */
    @ApiModelProperty(value = "店铺id")
    @TableField("store_id")
    @Excel(name = "店铺id")
    private Long storeId;

    /**
     * 店铺名称
     */
    @ApiModelProperty(value = "店铺名称")
    @NotEmpty(message = "店铺名称不能为空")
    @Length(max = 200, message = "店铺名称长度不能超过200")
    @TableField(value = "store_name", condition = LIKE)
    @Excel(name = "店铺名称")
    private String storeName;

    /**
     * 会员id
     */
    @ApiModelProperty(value = "会员id")
    @TableField("mid")
    @Excel(name = "会员id")
    private Long mid;

    /**
     * 父订单主键id
     */
    @ApiModelProperty(value = "父订单主键id")
    @NotNull(message = "父订单主键id不能为空")
    @TableField("parent_id")
    @Excel(name = "父订单主键id")
    private Long parentId;

    /**
     * 父订单编号
     */
    @ApiModelProperty(value = "父订单编号")
    @Length(max = 32, message = "父订单编号长度不能超过32")
    @TableField(value = "parent_code", condition = LIKE)
    @Excel(name = "父订单编号")
    private String parentCode;

    /**
     * 订单编号
     */
    @ApiModelProperty(value = "订单编号")
    @Length(max = 32, message = "订单编号长度不能超过32")
    @TableField(value = "order_code", condition = LIKE)
    @Excel(name = "订单编号")
    private String orderCode;

    /**
     * 订单状态：1-待付款 2-待发货 3-待收货 4-已完成 5-已取消
     */
    @ApiModelProperty(value = "订单状态：1-待付款 2-待发货 3-待收货 4-已完成 5-已取消")
    @NotNull(message = "订单状态：1-待付款 2-待发货 3-待收货 4-已完成 5-已取消不能为空")
    @TableField("order_status")
    @Excel(name = "订单状态：1-待付款 2-待发货 3-待收货 4-已完成 5-已取消")
    private Integer orderStatus;

    /**
     * 支付状态：1-已支付 0-未支付
     */
    @ApiModelProperty(value = "支付状态：1-已支付 0-未支付")
    @NotNull(message = "支付状态：1-已支付 0-未支付不能为空")
    @TableField("pay_status")
    @Excel(name = "支付状态：1-已支付 0-未支付")
    private Integer payStatus;

    /**
     * 下单账户
     */
    @ApiModelProperty(value = "下单账户")
    @Length(max = 255, message = "下单账户长度不能超过255")
    @TableField(value = "member_account", condition = LIKE)
    @Excel(name = "下单账户")
    private String memberAccount;

    /**
     * 发货时所用的物流公司的主键id
     */
    @ApiModelProperty(value = "发货时所用的物流公司的主键id")
    @NotNull(message = "发货时所用的物流公司的主键id不能为空")
    @TableField("logistics_id")
    @Excel(name = "发货时所用的物流公司的主键id")
    private Long logisticsId;

    /**
     * 物流公司编码
     */
    @ApiModelProperty(value = "物流公司编码")
    @NotEmpty(message = "物流公司编码不能为空")
    @Length(max = 32, message = "物流公司编码超过32")
    @TableField(value = "shipper_code", condition = LIKE)
    @Excel(name = "物流公司编码")
    private String shipperCode;

    /**
     * 发货时所用的物流公司的名称
     */
    @ApiModelProperty(value = "发货时所用的物流公司的名称")
    @NotEmpty(message = "发货时所用的物流公司的名称不能为空")
    @Length(max = 256, message = "发货时所用的物流公司的名称长度不能超过256")
    @TableField(value = "logistics_name", condition = LIKE)
    @Excel(name = "发货时所用的物流公司的名称")
    private String logisticsName;

    /**
     * 发货物流单号
     */
    @ApiModelProperty(value = "发货物流单号")
    @NotEmpty(message = "发货物流单号不能为空")
    @Length(max = 32, message = "发货物流单号长度不能超过32")
    @TableField(value = "logistics_num", condition = LIKE)
    @Excel(name = "发货物流单号")
    private String logisticsNum;

    /**
     * 物流方案
     */
    @ApiModelProperty(value = "物流方案")
    @Length(max = 255, message = "物流方案长度不能超过255")
    @TableField(value = "logistics_case", condition = LIKE)
    @Excel(name = "物流方案")
    private String logisticsCase;

    /**
     * 售后状态：-1 无售后 1-有退款 2-有退货
     */
    @ApiModelProperty(value = "售后状态：-1 无售后 1-有退款 2-有退货")
    @NotNull(message = "售后状态：-1 无售后 1-有退款 2-有退货不能为空")
    @TableField("return_type")
    @Excel(name = "售后状态：-1 无售后 1-有退款 2-有退货")
    private Integer returnType;

    /**
     * 国家
     */
    @ApiModelProperty(value = "国家")
    @NotEmpty(message = "国家不能为空")
    @Length(max = 20, message = "国家长度不能超过20")
    @TableField(value = "country", condition = LIKE)
    @Excel(name = "国家")
    private String country;

    /**
     * 国家id
     */
    @ApiModelProperty(value = "国家id")
    @NotNull(message = "国家id不能为空")
    @TableField("country_id")
    @Excel(name = "国家id")
    private Integer countryId;

    /**
     * 省份
     */
    @ApiModelProperty(value = "省份")
    @NotEmpty(message = "省份不能为空")
    @Length(max = 20, message = "省份长度不能超过20")
    @TableField(value = "province", condition = LIKE)
    @Excel(name = "省份")
    private String province;

    /**
     * 省份id
     */
    @ApiModelProperty(value = "省份id")
    @NotNull(message = "省份id不能为空")
    @TableField("province_id")
    @Excel(name = "省份id")
    private Integer provinceId;

    /**
     * 城市
     */
    @ApiModelProperty(value = "城市")
    @NotEmpty(message = "城市不能为空")
    @Length(max = 20, message = "城市长度不能超过20")
    @TableField(value = "city", condition = LIKE)
    @Excel(name = "城市")
    private String city;

    /**
     * 城市id
     */
    @ApiModelProperty(value = "城市id")
    @NotNull(message = "城市id不能为空")
    @TableField("city_id")
    @Excel(name = "城市id")
    private Integer cityId;

    /**
     * 地区
     */
    @ApiModelProperty(value = "地区")
    @NotEmpty(message = "地区不能为空")
    @Length(max = 20, message = "地区长度不能超过20")
    @TableField(value = "district", condition = LIKE)
    @Excel(name = "地区")
    private String district;

    /**
     * 地区id
     */
    @ApiModelProperty(value = "地区id")
    @NotNull(message = "地区id不能为空")
    @TableField("district_id")
    @Excel(name = "地区id")
    private Integer districtId;

    /**
     * 详细地址
     */
    @ApiModelProperty(value = "详细地址")
    @NotEmpty(message = "详细地址不能为空")
    @Length(max = 250, message = "详细地址长度不能超过250")
    @TableField(value = "address", condition = LIKE)
    @Excel(name = "详细地址")
    private String address;

    /**
     * 收货人名称
     */
    @ApiModelProperty(value = "收货人名称")
    @NotEmpty(message = "收货人名称不能为空")
    @Length(max = 50, message = "收货人名称长度不能超过50")
    @TableField(value = "rec_name", condition = LIKE)
    @Excel(name = "收货人名称")
    private String recName;

    /**
     * 收货人电话
     */
    @ApiModelProperty(value = "收货人电话")
    @NotEmpty(message = "收货人电话不能为空")
    @Length(max = 30, message = "收货人电话长度不能超过30")
    @TableField(value = "rec_mobile", condition = LIKE)
    @Excel(name = "收货人电话")
    private String recMobile;

    /**
     * 运费
     */
    @ApiModelProperty(value = "运费")
    @NotNull(message = "运费不能为空")
    @TableField("post_fee")
    @Excel(name = "运费")
    private Long postFee;

    /**
     * 订单金额
     */
    @ApiModelProperty(value = "订单金额")
    @NotNull(message = "订单金额不能为空")
    @TableField("order_sum")
    @Excel(name = "订单金额")
    private Long orderSum;

    /**
     * 订单消费金额
     */
    @ApiModelProperty(value = "订单消费金额")
    @NotNull(message = "订单消费金额")
    @TableField("discount_amount")
    @Excel(name = "订单消费金额")
    private Long discountAmount;

    /**
     * 支付金额
     */
    @ApiModelProperty(value = "支付金额")
    @NotNull(message = "支付金额不能为空")
    @TableField("pay_sum")
    @Excel(name = "支付金额")
    private Long paySum;

    /**
     * 发货时间
     */
    @ApiModelProperty(value = "发货时间")
    @TableField("send_time")
    @Excel(name = "发货时间", format = DEFAULT_DATE_TIME_FORMAT, width = 20)
    private LocalDateTime sendTime;

    /**
     * 确认收货的时间
     */
    @ApiModelProperty(value = "确认收货的时间")
    @TableField("confirm_time")
    @Excel(name = "确认收货的时间", format = DEFAULT_DATE_TIME_FORMAT, width = 20)
    private LocalDateTime confirmTime;

    /**
     * 退款时间
     */
    @ApiModelProperty(value = "退款时间")
    @TableField("return_money_time")
    @Excel(name = "退款时间", format = DEFAULT_DATE_TIME_FORMAT, width = 20)
    private LocalDateTime returnMoneyTime;

    /**
     * 下单时的备注
     */
    @ApiModelProperty(value = "下单时的备注")
    @NotEmpty(message = "下单时的备注不能为空")
    @Length(max = 1024, message = "下单时的备注长度不能超过1024")
    @TableField(value = "notes", condition = LIKE)
    @Excel(name = "下单时的备注")
    private String notes;

    /**
     * 预支付id
     */
    @ApiModelProperty(value = "预支付id")
    @Length(max = 255, message = "预支付id长度不能超过255")
    @TableField(value = "prepay_id", condition = LIKE)
    @Excel(name = "预支付id")
    private String prepayId;

    /**
     * 付款时间
     */
    @ApiModelProperty(value = "付款时间")
    @TableField("pay_time")
    @Excel(name = "付款时间", format = DEFAULT_DATE_TIME_FORMAT, width = 20)
    private LocalDateTime payTime;

    /**
     * 支付方式 1-微信支付 2-支付宝支付
     */
    @ApiModelProperty(value = "支付方式 1-微信支付 2-支付宝支付")
    @NotNull(message = "支付方式 1-微信支付 2-支付宝支付不能为空")
    @TableField("pay_channel")
    @Excel(name = "支付方式 1-微信支付 2-支付宝支付")
    private Integer payChannel;

    /**
     * 支付单号
     */
    @ApiModelProperty(value = "支付单号")
    @Length(max = 128, message = "支付单号长度不能超过128")
    @TableField(value = "pay_num", condition = LIKE)
    @Excel(name = "支付单号")
    private String payNum;

    /**
     * 营销活动id
     */
    @ApiModelProperty(value = "营销活动id")
    @TableField("promotion_id")
    @Excel(name = "营销活动id")
    private Long promotionId;

    /**
     * 优惠券id
     */
    @ApiModelProperty(value = "优惠券id")
    @TableField("coupon_id")
    @Excel(name = "优惠券id")
    private Long couponId;

    /**
     * 逻辑删除 1-删除 0-未删除
     */
    @ApiModelProperty(value = "逻辑删除 1-删除 0-未删除")
    @NotNull(message = "逻辑删除 1-删除 0-未删除不能为空")
    @TableField("is_delete")
    @Excel(name = "逻辑删除 1-删除 0-未删除")
    private Integer isDelete;


    @Builder
    public Order(Long id, Long createUser, LocalDateTime createTime, Long updateUser, LocalDateTime updateTime, 
                    Long storeId, String storeName, Long mid, Long parentId, String parentCode, 
                    String orderCode, Integer orderStatus, Integer payStatus, String memberAccount, Long logisticsId, String shipperCode, String logisticsName,
                    String logisticsNum, String logisticsCase, Integer returnType, String country, Integer countryId, String province, 
                    Integer provinceId, String city, Integer cityId, String district, Integer districtId, String address, 
                    String recName, String recMobile, Long postFee, Long orderSum, Long discountAmount, Long paySum, LocalDateTime sendTime,
                    LocalDateTime confirmTime, LocalDateTime returnMoneyTime, String notes, String prepayId, LocalDateTime payTime, Integer payChannel, 
                    String payNum, Long promotionId, Long couponId, Integer isDelete) {
        this.id = id;
        this.createUser = createUser;
        this.createTime = createTime;
        this.updateUser = updateUser;
        this.updateTime = updateTime;
        this.storeId = storeId;
        this.storeName = storeName;
        this.mid = mid;
        this.parentId = parentId;
        this.parentCode = parentCode;
        this.orderCode = orderCode;
        this.orderStatus = orderStatus;
        this.payStatus = payStatus;
        this.memberAccount = memberAccount;
        this.logisticsId = logisticsId;
        this.shipperCode = shipperCode;
        this.logisticsName = logisticsName;
        this.logisticsNum = logisticsNum;
        this.logisticsCase = logisticsCase;
        this.returnType = returnType;
        this.country = country;
        this.countryId = countryId;
        this.province = province;
        this.provinceId = provinceId;
        this.city = city;
        this.cityId = cityId;
        this.district = district;
        this.districtId = districtId;
        this.address = address;
        this.recName = recName;
        this.recMobile = recMobile;
        this.postFee = postFee;
        this.orderSum = orderSum;
        this.discountAmount = discountAmount;
        this.paySum = paySum;
        this.sendTime = sendTime;
        this.confirmTime = confirmTime;
        this.returnMoneyTime = returnMoneyTime;
        this.notes = notes;
        this.prepayId = prepayId;
        this.payTime = payTime;
        this.payChannel = payChannel;
        this.payNum = payNum;
        this.promotionId = promotionId;
        this.couponId = couponId;
        this.isDelete = isDelete;
    }

}
